﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ZK.HardWareBLL;

namespace ZK.YHP_TransManage.UC
{
    public partial class SNReader : UserControl
    {
        /// <summary>
        /// 室内读卡器
        /// </summary>
        private MHSNReaderBLL mHSNReader;
        public SNReader()
        {
            InitializeComponent();
            Common.DelegateHelper.MWSNMessageReceivedEvent += MWSNMessageReceivedEvent1;
            mHSNReader = new MHSNReaderBLL();
        }


        private void MWSNMessageReceivedEvent1(string carNum)
        {
            this.Invoke(new Action(() =>
            {
                textBox1.Text = carNum;
            }));
        }

        /// <summary>
        /// 读卡按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button1_Click(object sender, EventArgs e)
        {
            mHSNReader.ReadCard();
        }

        /// <summary>
        /// 关闭 close
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button2_Click(object sender, EventArgs e)
        {
            mHSNReader.CloseRes();
        }

        /// <summary>
        /// 写卡
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button3_Click(object sender, EventArgs e)
        {
            mHSNReader.WriteCard(textBox1.Text, textBox2.Text);
        }
    }
}
